package cn.itcast.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Arrays;

/**
 * @author 虎哥
 */
@Controller
public class HelloController {

    /**
     * 返回一个视图，名称为hello \r\n
     * InternalResourceViewResolver视图解析器，配置: \r\n
     *  prefix: /WEB-INF/views/ \r\n
     *  suffix: *.jsp \r\n
     * 寻找视图： prefix + viewName + suffix
     * @return
     */
    @GetMapping("hello")
    public String hello(Model model){
        model.addAttribute("name", "Jack Jones");
        model.addAttribute("students", Arrays.asList("刘亦菲", "古力娜扎", "迪丽热巴", "虎哥", "范冰冰"));
        return "hello";
    }
}
